﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel.DomainServices.Server;
using System.ServiceModel.DomainServices.Hosting;

namespace Imtihan.Web
{
    public partial class ImtihanDomainService
    {
        /// <summary>
        /// Get user assessment schedule by passing assessment schedule id.
        /// </summary>
        /// <param name="assessmentScheduleId">assessment schedule id.</param>
        /// <returns>User assessment schedule for specific assessment schedule.</returns>
        [Invoke]
        public UserAssessmentSchedule GetUserAssessmentScheduleByAssessmentScheduleIdAndUserId(Guid assessmentScheduleId, string userId)
        {
            return this.ObjectContext.UserAssessmentSchedules.Include("AssessmentSchedule").Include("User").Where(uaSched => uaSched.AssessmentScheduleId
                == assessmentScheduleId && uaSched.UserId.ToLower() == userId.ToLower()).FirstOrDefault();
        }

        /// <summary>
        /// Get user assessment schedules by passing assessment schedule id.
        /// </summary>
        /// <param name="assessmentScheduleId">assessment schedule id.</param>
        /// <returns>List of user assessment schedule for specific assessment schedule.</returns>
        [Invoke]
        public List<UserAssessmentSchedule> GetUserAssessmentSchedulesByAssessmentScheduleId(Guid assessmentScheduleId)
        {
            return this.ObjectContext.UserAssessmentSchedules.Where(uaSched => uaSched.AssessmentScheduleId == assessmentScheduleId).ToList();
        }
    }
}